package com.hd.boot0407.controller;

import com.baomidou.kaptcha.Kaptcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/kap")
public class KaptchaController {
    @Autowired
    private Kaptcha kaptcha;

    @GetMapping( "/render")
    public void render () {
        kaptcha.render ();
    }

    @GetMapping("/login")
    public String login(String username,String pwd ,String cap){
        boolean validate = kaptcha.validate(cap);
        return validate+"";
    }

}
